#ifndef BJGAME_H
#define BJGAME_H

class BJHand;

class BJSavedGame;
class BJBet
{
	private:
		BJRules*		m_pRules;
        uint8           m_iBJBet;
        bool8           m_dealerEnded;

	public:
		BJBet(BJGame* game, BJConnection* conn, BJRules* pRules, 
			BJHand* dealer, BJHand* player, int32 bet, int8);

		BJBet(BJGame* game, BJConnection* conn, BJRules* pRules, 
			BJHand* dealer, BJHand* player, BJSavedGame* sg  , int8);


		~BJBet();
        char   *GetGID() { return gid; }

        enum InsuranceState { NO='N', OFFERED='O', DECLINED='D', TAKEN='T', WON='W', LOST='L' };

        bool8   PlayerDeal();
		uint8	GetPlayerAction();
		bool8	HandlePlayerHit			(int32 balance);
		bool8	HandlePlayerStand		();
		bool8	HandlePlayerDouble		(int32 balance);
		bool8	HandlePlayerSplit		(int32 balance);
		bool8	HandlePlayerSurrender	(int32 balance);
		/// [2013-07-10] Charles. Added for supporting 'Zappit Rackcard'.
		bool8	HandlePlayerZap	(int32 balance);
		bool8	HandlePlayerNextAction(int32 balance);
		void	HandlePlayerPayout();

		void	RenumberHands();

		int32	GetBet();
        uint8   GetBetOffset() { return m_iBJBet; }


		BJHand* getCurrentHand() {	return current; }

		int32	getHands() { return splitCount+1; }
        void    SetDealerEnded() { m_dealerEnded = true; }
        bool8   IsDealerEnded() { return m_dealerEnded; }

		void sendState();

		int32 GetCurrentBet();


		bool8	HandlePlayerInsurance( int32 Amt );
		void	HandlePlayerInsurancePayout();

        int32   GetCurrentHandOffset() { return currentHand; }
        void    SetCurrentHandOffset( int32 cH );

		InsuranceState	GetInsuranceState() {	return m_insuranceState; }
		void	SetInsuranceState( InsuranceState st ) {	m_insuranceState=st; }

        void    sendPayouts();
		bool8	EndOfTurnPlayer();
		uint8	GetPlayerOptions();

		//osegura 08/20/2008. FB case 22886
		BJHand	*getPlayerHand() { return player; }

	protected:
		BJGame*			game;
		BJConnection*	conn;
	    char   	        gid[BJ_GAMEID_SIZE];

		BJHand*			dealer;
		BJHand*			player;
		BJHand*			current;

        int32			m_bet;
		int32			splitCount;
		int32			currentHand;

		InsuranceState	m_insuranceState;
		int32			m_insurance;

		//
		// *IMPORTANT*  When adding/changing here, be sure to update
		//				constructors/destructor, send(), save(), restore()
		//
};

inline int32
BJBet::GetBet()
{
	return m_bet;
}


#endif
